package org.artifact.core.plugin.netty.codec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class ByteArrayEncoder extends MessageToByteEncoder<byte[]> {

	@Override
	protected void encode(ChannelHandlerContext ctx, byte[] data, ByteBuf out) throws Exception {
		out.writeInt(data.length);
		out.writeBytes(data);
	}
}
